﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XinjeMesProgram.Entities.RoleAndUser;

namespace XinjeMesProgram.Entities.RoleAndUser
{
    /// <summary>
    /// 角色实体类
    /// </summary>
    public class AuthRole
    {
        /// <summary>
        /// 
        /// </summary>
        public AuthRole()
        {
            UserRoles = new HashSet<AuthUserRoleMapping>();
            Permissions = new HashSet<RolePermissionMapping>();
        }
        /// <summary>
        /// 
        /// </summary>
        [Required]
        [Key]
        [Column(TypeName = "nvarchar(50)")]
        public string Code { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [Required]
        [Column(TypeName = "nvarchar(50)")]
        public string Name { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [Column(TypeName = "nvarchar(50)")]
        public string Description { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public CommonEnum.Status Status { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public CommonEnum.IsDeleted IsDeleted { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedOn { get; set; }
        /// <summary>
        /// 创建者ID
        /// </summary>
        [Column(TypeName = "varchar(100)")]
        public string CreatedByUserGuid { get; set; }
        /// <summary>
        /// 创建者姓名
        /// </summary>
        [Column(TypeName = "varchar(50)")]
        public string CreatedByUserName { get; set; }
        /// <summary>
        /// 是否是超级管理员(超级管理员拥有系统的所有权限)
        /// </summary>
        public int IsSuperAdministrator { get; set; }
        /// <summary>
        /// 是否是系统内置角色(系统内置角色不允许删除,修改操作)
        /// </summary>
        public int IsBuiltin { get; set; }

        /// <summary>
        /// 角色拥有的用户集合
        /// </summary>
        [NotMapped]
        public ICollection<AuthUserRoleMapping> UserRoles { get; set; }
        /// <summary>
        /// 角色拥有的权限集合
        /// </summary>
        [NotMapped]
        public ICollection<RolePermissionMapping> Permissions { get; set; }
    }
}
